Skip to content

WebSocket support via Mint.WebSocket#4

Merged
dannote merged 22 commits intomasterfrom
websocket
Apr 9, 2026
Merged

WebSocket support via Mint.WebSocket#4
dannote merged 22 commits intomasterfrom
websocket

Conversation

@dannote
Copy link
Copy Markdown
Member

@dannote dannote commented Mar 31, 2026

Mint-backed WebSocket client for QuickBEAM runtimes and contexts.

Backend — adds QuickBEAM.WebSocket on top of Mint.HTTP + Mint.WebSocket:

  • __ws_connect
  • __ws_send
  • __ws_close
  • async delivery of open / message / error / close events into JS

JS WebSocket API — updates the browser polyfill to match expected platform behavior:

  • ws: / wss: plus http: / https: normalization
  • protocol validation and duplicate rejection
  • binaryType handling for Blob and ArrayBuffer
  • close code / reason validation
  • bufferedAmount tracking
  • binary frame dispatch via runtime messages

Runtime integration — wires WebSockets into both:

  • QuickBEAM.Runtime
  • QuickBEAM.Context

WPT coverage — ports constructor / protocol / close / binary send cases plus context integration:

  • 17 WebSocket tests in test/wpt/wpt_websocket_test.exs

Docs

  • README.md
  • docs/javascript-api.md
  • docs/architecture.md

Also fixes swallowed QuickJS module-evaluation job errors so QuickBEAM.load_module/3 returns top-level module exceptions correctly.

Verified with:

  • mix test test/wpt/wpt_websocket_test.exs
  • QUICKBEAM_BUILD=1 mix test

dannote added 22 commits March 31, 2026 22:28
- close() during CONNECTING now fails the connection instead of opening first
- Constructor rejects URLs with credentials (username/password)
- Subprotocol dedup uses case-sensitive comparison per RFC 7936
- Better specs with named params for handler callbacks
- Document :global choice with rationale comment
- Extract shared websocket lifecycle into Server macro
- Use struct update consistently (no Map.put for struct keys)
- Consolidate dialyzer suppression to single module-level attr
@dannote dannote merged commit 706cfa9 into master Apr 9, 2026
4 checks passed
@dannote dannote deleted the websocket branch April 9, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant